package com.heim.kafka.listener;

import com.alibaba.fastjson.JSON;
import com.heim.kafka.pojo.User;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * ClassName: HelloListener
 * Package: com.heim.kafka.listener
 * Description:
 *
 * @Author 周阳阳
 * @Create 2024/10/21 20:41
 * @Version 1.0
 */
@Component
public class HelloListener {
    @KafkaListener(topics = "user-topic")
    public void onMessage(String message){
        if(!StringUtils.isEmpty(message)){
            User user = JSON.parseObject(message, User.class);
            System.out.println(user);
        }
    }
}
